Skip layout shift tracking for more invisible elements Besides the current conditions, e.g. visibility:hidden, opacity:0 (which is checked in PaintInvalidator instead of LayoutShiftTracker) etc., also ignore the following invisible elements: - For texts: - if the font is not renderable - if the text contains all whitespaces - For blocks: - if it doesn't have any decorations, and doesn't have any children. For performance and to reduce risk of false-negative of layout shift tracking, the conditions are kept simple. If a developer still get unexpected layout shift for invisible elements, we can suggest adding visibility:hidden to the element to explicitly disable layout shift tracking on the element. See https://ct.skia.org/results/cluster-telemetry/tasks/chromium_perf_runs/wangxianzhu-ChromiumPerf-5677/html/index.html for the change of overall CLS score with this CL. Bug: 1099350 Change-Id: Ib7e89e0331663572d1eef511976556e8b2a96a96 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2743811 Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by: Steve Kobes <skobes@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#862593} 
diff --git a/layout-instability/visibility-hidden-layout-and-visible.html b/layout-instability/visibility-hidden-layout-and-visible.html index 3fea6bb..35ee0d9 100644 --- a/layout-instability/visibility-hidden-layout-and-visible.html +++ b/layout-instability/visibility-hidden-layout-and-visible.html 
@@ -1,7 +1,7 @@  <!DOCTYPE html>  <title>Layout Instability: visibility:hidden change with layout</title>  <link rel="help" href="https://wicg.github.io/layout-instability/" /> -<div id="target" style="position: absolute; top: 0; width: 200px; height: 200px; visibility: hidden"></div> +<div id="target" style="position: absolute; top: 0; width: 200px; height: 200px; visibility: hidden; background: blue"></div>  <script src="/resources/testharness.js"></script>  <script src="/resources/testharnessreport.js"></script>  <script src="resources/util.js"></script>